package com.ccnu.JobHub.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccnu.JobHub.mapper.CommentMapper;
import com.ccnu.JobHub.model.database.Comment;
import com.ccnu.JobHub.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
    @Autowired
    private CommentMapper commentMapper;

    /**
     * 获取所有父评论为这个id的评论
     * @param parentId 父评论id
     * @return 一个list列表，包含某评论的所有子评论
     */
    @Override
    public List<Comment> getSonCommentsByParentId(Integer parentId){
        QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<Comment>()
                .eq("parent_comment_id",parentId);
        return commentMapper.selectList(commentQueryWrapper);
    }
}
